# 使用方法
# ./main ../src/keyword-spot-fsmn-ctc-wenwen/onnx/keyword_spot_fsmn_ctc_wenwen.onnx ../src/keyword-spot-fsmn-ctc-wenwen/tokens.txt ../src/test_shandong.pcm

cmake_minimum_required(VERSION 3.26)
project(kws-demo)

option(ONNXRUNTIME "Enable onnxrumtime inference" OFF)
option(MNNRUMTIME "Enable mnn inference" ON)

include_directories(
    ${PROJECT_SOURCE_DIR}/onnxruntime/include
    ${PROJECT_SOURCE_DIR}/MNN/include
    ${PROJECT_SOURCE_DIR}
)

if (ONNXRUNTIME)    
    add_definitions(-DONNXRUNTIME_INFER)
    link_directories(
        ${PROJECT_SOURCE_DIR}/onnxruntime/lib
    )
    link_libraries(onnxruntime)
elseif(MNNRUMTIME)    
    add_definitions(-DMNN_INFER)
    link_directories(
        ${PROJECT_SOURCE_DIR}/MNN/lib
    )
    link_libraries(MNN)
else()
    message(FATAL_ERROR "must choose onnxrumtime or mnn!")
endif()

set(SRC_
    ${PROJECT_SOURCE_DIR}/frontend/Feature.cc
    ${PROJECT_SOURCE_DIR}/frontend/fft.cc    
    ${PROJECT_SOURCE_DIR}/kws/utils.cpp
)

if (ONNXRUNTIME)
    list(APPEND SRC_ ${PROJECT_SOURCE_DIR}/kws/keyword_spotting.cc)
elseif(MNNRUMTIME)
    list(APPEND SRC_ ${PROJECT_SOURCE_DIR}/kws/keywordspotter.cc)
endif()

add_executable(main ${PROJECT_SOURCE_DIR}/src/demo_stream.cc ${SRC_})
